package com.qf.handler;

import com.qf.Exception.MyException;
import com.qf.vo.ResultVO;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.RestControllerAdvice;
//异常处理器
//@ControllerAdvice   //意思是要经过一次转发
@RestControllerAdvice //直   接返回，跨过了前端处理器
public class EbookEntryControllerhandler {
    @ExceptionHandler(Exception.class)
    public ResultVO Entry(Exception e){
    ResultVO resultVO=new ResultVO();
    resultVO.setCode(500);
    resultVO.setMsg(e.getMessage());
    return resultVO;
    }

    @ExceptionHandler(MyException.class)
    public ResultVO MyException(MyException e){
        ResultVO resultVO=new ResultVO();
        resultVO.setCode(500);
        resultVO.setMsg(e.getMessage());
        return resultVO;
    }

}
